package com.dg11185.nearshop.net.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class GetBrandListResponse {
    public String responseStr;
    public String statusStr;
    public NetStatus status = null;
    public String total = null;

    // public List<BrandStroe> brandStroes = null;
    public List<Brand> brandList;

    public GetBrandListResponse() {
        // brandStroes = new ArrayList<BrandStroe>();
    }

    public void parseJson(String response) {
        responseStr = response;
        try {
            JSONObject jsonObject = new JSONObject(response);
            status = NetStatus.getStatus(jsonObject.optString("status"));
            statusStr = jsonObject.optString("status");
            total = jsonObject.optString("total");

            if (!jsonObject.isNull("brandList")) {
                brandList = new ArrayList<GetBrandListResponse.Brand>();
                JSONArray brandArray = jsonObject.optJSONArray("brandList");
                for (int a = 0; a < brandArray.length(); a++) {
                    JSONObject j = brandArray.getJSONObject(a);
                    Brand b = new Brand();
                    b.brandId = j.getString("brandId");
                    b.name = j.getString("name");
                    b.describe = j.getString("description");
                    b.maxPhotoUrl = j.getString("maxPhotoUrl");
                    b.midPhotoUrl = j.getString("midPhotoUrl");
                    b.minPhotoUrl = j.getString("minPhotoUrl");

                    brandList.add(b);
                    // BrandStroe brand = new BrandStroe();
                    // brand.parseEntity(brandArray.getJSONObject(a));
                    // brandStroes.add(brand);
                }
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public class Brand {
        public String brandId;
        public String name;
        public String describe;
        public String maxPhotoUrl;
        public String midPhotoUrl;
        public String minPhotoUrl;
    }
}
